home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / mnpc12.zip / MNPDAT.H < prev    next >
C/C++ Source or Header  |  1987-12-16  |  8KB  |  205 lines

  1. /***************************************************************************
  2.  
  3.                  General MNP Definitions
  4.  
  5.     8/27/87 - RBUF_LEN increased to 576..gp
  6.     10/29/87 - explict data typing..gp
  7.  
  8. ***************************************************************************/
  9.  
  10. /* Data Types 
  11. */
  12. #define SIGN_8 signed char
  13. #define USIGN_8 unsigned char
  14. #define SIGN_16 signed short int
  15. #define USIGN_16 unsigned short int
  16.  
  17. #define SUCCESS     0    /* success return code from all functions */
  18. #define TRUE        1
  19. #define FALSE        0
  20.  
  21. /*-------------------- Return Codes used by LLVL -------------------------*/
  22.  
  23. #define FAILURE      (-64)    /* no further information */
  24. #define TIME_OUT     (-65)    /* timeout */
  25. #define NO_PHYSICAL  (-66)    /* physical connection down */
  26. #define LNK_DOWN     (-67)    /* link connection down */
  27.                 /* see mnp_cb.ld_reason for LD reason code */
  28. #define LR_CODE      (-73)    /* when there is an error in parsing an LR,
  29.                    an LD is sent back with reason code (1-5)
  30.                    LR_CODE is added to that reason code and
  31.                    returned as one of the 5 error codes below
  32.  
  33.               -72    received LPDU not LR as expected
  34.               -71    reserved
  35.               -70    incompatible or unknown parameters
  36.               -69    reserved
  37.               -68    reserved
  38.                 */
  39.  
  40. #define BUFF_ERR     (-75)    /* buffer error */
  41.  
  42. /* -----------------------------------------------------------------------*/
  43.  
  44. #define NULL        0
  45.  
  46. /* Protocol Data Units */
  47.  
  48. #define LR        1
  49. #define LD        2
  50. #define LT        4
  51. #define LA        5
  52. #define LN        6
  53. #define LNA        7
  54.  
  55. /* Protocol Data Units Formats (Offsets) */
  56.  
  57. #define PDU_LI        0        /* header length indicator */
  58. #define PDU_TYPE    1        /* type of pdu */
  59.  
  60. /***************************************************************************
  61. *                                       *
  62. *            Buffer Management Definitions               *
  63. *                                       *
  64. ***************************************************************************/
  65.  
  66.  
  67. /* each blst (buffer list) structure controls an actual buffer */
  68.  
  69. struct BLST {
  70.     USIGN_16 mark;            /* 0: free | 1: used */
  71.     USIGN_8 *bptr;            /* pointer to the actual buffer */
  72.     USIGN_16 len;            /* lenght of data in buffer */
  73.     struct BLST *next_b;        /* pointer to next structure */
  74. };
  75.  
  76. /* each buffer structure controls a linked list of blst structures */
  77.  
  78. struct BUFFER {
  79.     struct BLST *list;        /* pointer to head node */
  80.     struct BLST *free;        /* pointer to node with free buffer */
  81.     USIGN_16 num;            /* total number of nodes (buffers) */
  82.     USIGN_16 used;            /* number of buffers being used */
  83.     struct BLST *used_lst;        /* pointer to head of list
  84.                       of buffers in use */
  85.     struct BLST *next_lst;
  86. };
  87.  
  88. #define BIT0_ON     (0x01)
  89.  
  90. /***************************************************************************
  91.  
  92.                      LLVL Definitions
  93.  
  94. ***************************************************************************/
  95.  
  96. /* Link Disconnect reason code */
  97. #define PROT_ERR        1
  98. #define PROT_LVL_MISMATCH    2
  99. #define BAD_LR_PARMS        3
  100. #define RETRAN_TMR_EXP        4
  101. #define INACT_TMR_EXP        5
  102.  
  103. struct link_ctl_blk {
  104.     /* variables initialized at one-time initialization */
  105.     USIGN_8 status_1;        /* link status */
  106.     USIGN_8 status_2;        /* link status */
  107.     USIGN_8 status_3;        /* link status */
  108.     USIGN_16 ack_timer;        /* acknowledgement timer value */
  109.     USIGN_16 max_data_sz;    /* negotiated maximum user data size */
  110.     USIGN_16 prot_level;     /* negotiated protocol level */
  111.     USIGN_16 lt_tmr;        /* lt (data) retransmission timer value */
  112.     USIGN_16 srv_class;        /* local service class */
  113.     USIGN_16 window_sz;        /* negotiated window size */
  114.     USIGN_16 window_tmr;     /* flow control window timer value */
  115.     USIGN_8 baud_rate;        /* current link baud rate */
  116.     USIGN_8 ln_rsn;        /* last ln (remote) receive sequence number */
  117.     USIGN_8 ln_ssn;        /* last ln (local) send sequence number */
  118.  
  119.     /* variables initialized/reset at link reset */
  120.     USIGN_8 ltssn_acked;    /* last lt sent seq. # that has been acked */
  121.                         /* by remote link */
  122.     USIGN_8 ltrsn_acked;    /* last lt received seq. # that has been */
  123.                 /* acked by local link */
  124.     USIGN_8 lt_rsn;        /* last lt (remote) received sequence number */
  125.     USIGN_8 lt_ssn;        /* last lt (local) sent sequence number */
  126.     USIGN_16 ln_ret_cnt;     /* ln retransmission count */
  127.     USIGN_16 lt_ret_cnt;     /* lt retransmission count */
  128.  
  129.     /* variables initialized at start of data phase */
  130.     USIGN_16 ack_threshold;    /* acknowledgement threshold */
  131.     USIGN_16 lcl_credit;     /* receive (local) credit */
  132.     USIGN_16 rem_credit;     /* send (remote) credit */
  133.  
  134.     /* other variables */
  135.     USIGN_16 l_disc_code;    /* link layer disconnect code */
  136.     USIGN_16 ln_rtype;        /* ln lpdu type received */
  137.     USIGN_16 ln_stype;        /* ln lpdu type to be sent */
  138.     USIGN_16 lpdu_type;        /* type of last lpdu received */
  139.     USIGN_16 u_disc_code;    /* user disconnect code */
  140.     USIGN_8 lr_parm;        /* lr parameter flag */
  141. };
  142.  
  143. /* Link Status Byte 1 bit definition (lcb.status_1)
  144. */
  145. #define LA_RECEIVED    1    /* on: la lpdu received */
  146. #define LINK_EST    2    /* on: link established */
  147. #define DATA_READY    4    /* on: user data available (lt received) */
  148. #define ACK_TIMER    8    /* on: timer set */
  149. #define RET_TIMER    16    /* on: retran timer set */
  150. #define MODE        32    /* on: acceptor ║ off: initiator */
  151. #define HDUPLEX     64    /* on: half duplex ║ off: full duplex */
  152. #define ACK        128    /* on: ack needed - normal ack sequence */
  153.  
  154. /* Link Status Byte 2 bit definition (lcb.status_2)
  155. */
  156. #define FORCE_ACK    1    /* on: force ack needed - lt received bad */
  157. #define FORCE_RET    2    /* on: lt retran needed - la received bad */
  158. #define ZERO_WNDW    4    /* on: zero window in effect */
  159. #define WNDW_TIMER    8    /* on: flow control window timer set */
  160.  
  161. /* Link Status Byte 3 bit definition (lcb.status_3)
  162. */
  163. #define LN_RECEIVED    1    /* on: ln lpdu received */
  164. #define LNA_RECEIVED    2    /* on: lna lpdu received */
  165. #define FORCE_LNA    4    /* on: need to send an lna lpdu */
  166. #define LN_TIMER    16    /* on: ln retran timer set */
  167. #define DUP_IGNORED    32    /* on: received an immediate duplicate LT */
  168.                 /*     it was ignored */
  169. #define LN_SENT    64    /* on: ln lpdu sent, not acked */
  170.  
  171. /* timer event flag definition */
  172. #define FRAME_SND    1    /* frame has been sent */
  173. #define FRAME_RCV    2    /* a frame has been received */
  174. #define FRAME_DN    3    /* frame sent, including end flag */
  175.  
  176. /* offsets of LPDU */
  177. #define LT_SEQ        4    /* sequence number in LT */
  178.  
  179. /* Stream link buffer definitions */
  180. #define RBUF_LEN    576
  181. #define SBUF_LEN    1024
  182.  
  183. /***************************************************************************
  184. *                                       *
  185. *            MNP Control Block Definitions               *
  186. *                                       *
  187. ***************************************************************************/
  188.  
  189. struct MNP_CB {
  190.     SIGN_16 (*l_connect)();    /* function to establish a link connection */
  191.     SIGN_16 (*l_disconnect)();    /* function to disconnect a link connection */
  192.     SIGN_16 (*l_link)();    /* function to maintain link */
  193.     SIGN_16 (*lt_send)();    /* function to send an lt lpdu */
  194.     SIGN_16 (*lt_receive)();    /* function to receive an lt lpdu */
  195.     SIGN_16 (*l_update)();    /* function to change link variables */
  196.     SIGN_16 (*ret_rcvbuf)();    /* function to return a receive buffer */
  197.     struct BUFFER *rb;    /* addr of struct to control receive buffers */
  198.     struct BUFFER *ftb;    /* addr of struct to control transmit buffers */
  199.     struct BUFFER *rlkb;    /* addr of struct to control lnk rec buffers */
  200.     struct BUFFER *lkb;    /* addr of struct to control lnk xmit buffers */
  201.     SIGN_16 ld_reason;        /* reason code in the received LD */
  202.     USIGN_16 ld_source;        /* disc source: 0=layer, 1=user */
  203.     USIGN_16 parity;        /* stream link parity type */
  204. };
  205.